package com.phkj.qdh.ui.adapter

import android.content.Context
import android.view.ViewGroup
import android.widget.CheckBox
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.phkj.qdh.R
import com.phkj.qdh.bean.ZheDiThing

class FailoverThingsAdapter : BaseQuickAdapter<ZheDiThing, QuickViewHolder>() {
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: ZheDiThing?) {
        val cb = holder.getView<CheckBox>(R.id.cb)
        cb.setOnCheckedChangeListener(null)
        cb.isChecked = item!!.isSelected
        holder.setText(R.id.tv_state,item.problemStatus)
        when (item.eventType) {
            0 -> {
                holder.setText(R.id.tv_type1, "巡查类型：")
                holder.setText(R.id.tv_type_name1, item.problemFirstType)
                holder.setText(R.id.tv_type2, "问题类型：")
                holder.setText(R.id.tv_type_name2, item.disposalMethod)
                holder.setText(R.id.tv_type3, "问题：")
                holder.setText(R.id.tv_type_name3, item.problemSecondType)
            }
            else -> {
                holder.setText(R.id.tv_type1, "场所类型：")
                holder.setText(R.id.tv_type_name1, item.problemFirstType)
                holder.setText(R.id.tv_type2, "问题类型：")
                holder.setText(R.id.tv_type_name2, item.disposalMethod)
                holder.setText(R.id.tv_type3, "场所名称：")
                holder.setText(R.id.tv_type_name3, item.problemSecondType)
            }
        }

        holder.setText(R.id.tv_date, item.createTime ?: "")
    }

    override fun onCreateViewHolder(
        context: Context, parent: ViewGroup, viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_failover_things, parent)
    }
}